home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
zbpc_460.zip
/
UTILITY.EXE
/
KEY.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-06-06
|
17KB
|
360 lines
00004 REM: key.z
00010 REM: WRITTEN BY JOE PHILLIPS, 1991, Modifications for 4.6 by Harry A. Gish
00050 CLEAR:DIM 50IN$(650),LX(10),LY(10)
00052 :REM == Key Values for ease of Key recognition.
00054 :REM == Note : Extended Key Values ( LEN = 2 ) have 128 added to their
00056 :REM == KeyValue if you use the input routine provided.
00058 BACKSP = 8: PGUP = 201: CTRLPGUP = 138:
00060 T_A_B = 9: PGDN = 209: CTRLPGDN = 246:
00062 ENTER = 13: E_N_D = 207: CTRLE_N_D= 245:
00064 ESC = 27: HOME = 199: CTRLHOME = 247:
00066 ST_A_B = 143: INS = 210: DEL = 211:
00068 LArrow = 203: CTRLLArrow = 243:
00070 RArrow = 205: CTRLRArrow = 244:
00072 UArrow = 200:
00074 DArrow = 208:
00076 CTRLA = 1: ALTA = 158: ALT1 = 248:
00078 CTRLB = 2: ALTB = 176: ALT2 = 249:
00080 CTRLC = 3: ALTC = 174: ALT3 = 250:
00082 CTRLD = 4: ALTD = 160: ALT4 = 251:
00084 CTRLE = 5: ALTE = 146: ALT5 = 252:
00086 CTRLF = 6: ALTF = 161: ALT6 = 253:
00088 CTRLG = 7: ALTG = 162: ALT7 = 254:
00090 CTRLH = 8: ALTH = 163: ALT8 = 255:
00092 CTRLI = 9: ALTI = 151: ALT9 = 134:
00094 CTRLJ = 10: ALTJ = 164: ALT0 = 135:
00096 CTRLK = 11: ALTK = 165: ALTMINUS = 136:
00098 CTRLL = 12: ALTL = 166: ALTEQUALS = 137:
00100 CTRLM = 13: ALTM = 178:
00102 CTRLN = 14: ALTN = 177:
00104 CTRLO = 15: ALT_O = 152:
00106 CTRLP = 16: ALTP = 153:
00108 CTRLQ = 17: ALTQ = 144:
00110 CTRLR = 18: ALTR = 147:
00112 CTRLS = 19: ALTS = 159:
00114 CTRLT = 20: ALTT = 148:
00116 CTRLU = 21: ALTU = 150:
00118 CTRLV = 22: ALTV = 175:
00120 CTRLW = 23: ALTW = 145:
00122 CTRLX = 24: ALTX = 173:
00124 CTRLY = 25: ALTY = 149:
00126 CTRLZ = 26: ALTZ = 172:
00128 F1 = 187: SF1 = 212:
00130 F2 = 188: SF2 = 213:
00132 F3 = 189: SF3 = 214:
00134 F4 = 190: SF4 = 215:
00136 F5 = 191: SF5 = 216:
00138 F6 = 192: SF6 = 217:
00140 F7 = 193: SF7 = 218:
00142 F8 = 194: SF8 = 219:
00144 F9 = 195: SF9 = 220:
00146 F10 = 196: SF10 = 221:
00148 F11 = 139: SF11 = 141:
00150 F12 = 140: SF12 = 142:
00152 CTRLF1 = 222: ALTF1 = 232:
00154 CTRLF2 = 223: ALTF2 = 233:
00156 CTRLF3 = 224: ALTF3 = 234:
00158 CTRLF4 = 225: ALTF4 = 235:
00160 CTRLF5 = 226: ALTF5 = 236:
00162 CTRLF6 = 227: ALTF6 = 237:
00164 CTRLF7 = 228: ALTF7 = 238:
00166 CTRLF8 = 229: ALTF8 = 239:
00168 CTRLF9 = 230: ALTF9 = 240:
00170 CTRLF10 = 231: ALTF10 = 241:
00172 CTRLF11 = 154: ALTF11 = 156:
00174 CTRLF12 = 155: ALTF12 = 157:
00176 DIM 2TmpKey$, 2Isaskist$
00178 DEF FN F_Isaski(Isaskist$) = ( (VAL(Isaskist$)>31) AND (VAL(Isaskist$)<127) AND (LEN(Isaskist$)=1) )
00180 LONG FN Key$
00182 TmpKey$ = ""
00184 WHILE TmpKey$ = ""
00186 TmpKey$ = INKEY$
00188 WEND
00190 LONG IF ( LEN(TmpKey$) = 2 )
00192 TPKey$ = RIGHT$(TmpKey$,1)
00194 KeyValue = ASC(TPKey$)+128
00196 XELSE
00198 KeyValue = ASC(TmpKey$)
00200 END IF
00202 :REM - Notice the following values are not inclusive
00204 Isaski = ( KeyValue > 31 ) AND ( KeyValue < 127 )
00206 END FN = TmpKey$
00208 DIM 2KY$
00210 LONG FN FCTKey
00212 REM Will Only allow a Function Key or Escape Key to be pressed
00214 SVVL = 0
00216 WHILE SVVL = 0
00218 KY$ = FN Key$
00220 LONG IF ( KeyValue >= F1 ) AND ( KeyValue <= F10 )
00222 SVVL = KeyValue - F1 + 1
00224 XELSE
00226 IF KeyValue = ESC THEN SVVL = -1
00228 END IF
00230 WEND
00232 END FN = SVVL
00234 LONG FN WAITKey
00236 :REM Assert : No Key Value Returned
00238 JUNK$ = FN Key$
00240 END FN :REM WaitKey
00242 :REM :
00244 :REM :
00246 :REM End Of Key Value Definitions And Related Routines :
00248 :REM---------------------------------------------------------------------
00250 :REM---------------------------------------------------------------------
00252 :REM FN Edit$ :
00254 :REM Joe Phillips - 1991 :
00256 :REM Created For I.S.D., Inc :
00258 :REM--------------------------------------------------------------------:
00260 TRUE = (1=1):FALSE = (1=0) :REM This is to assure theses values are set
00262 LONG FN Edit_DFLTS( F_C, B_C, FR_C, BR_C, FC, EB, EL )
00264 :REM Defaults for FN Edit$ may be set in this function
00266 :REM
00268 Edit_F = F_C :REM Fore Ground COLOR When Editting
00270 Edit_B = B_C :REM Back Ground COLOR When Editting
00272 Edit_FR = FR_C :REM Fore Ground COLOR When Not Editting
00274 Edit_BR = BR_C :REM Back Ground COLOR When Not Editting
00276 Edit_FLCH = FC :REM Default Fill Character, see below
00278 Edit_BRKT = EB :REM Switch to Display Brackets (TRUE = on )
00280 :REM (FALSE= Off )
00282 Edit_LEAVE = EL :REM Switch to Leave if field Full
00284 :REM TRUE = Leave when Full
00286 :REM Some Possibles for Fill Character
00288 :REM 250 [······] 176 [░░░] 95 [_] 45 [-] 32 [ ]
00290 END FN :REM Edit_Dflts
00292 :REM
00294 :REM Set Parameters in case the user forgets
00296 :REM The following lines of code will be executed at program start. Therefore,
00298 :REM if you set the variables by hand, you might have trouble. Use the
00300 :REM function provided !!!!! ( FN Edit_Dflt )
00302 Edit_F = 7
00304 Edit_B = 0
00306 Edit_FR = 7
00308 Edit_BR = 0
00310 Edit_FLCH = 32
00312 Edit_BRKT = (1=1) REM Turn On Brackets
00314 Edit_LEAVE = (1=1)
00316 :
00318 LONG FN Edit$( OLD$, COL, ROW,LGTH_Z, Edit_FMT ,Edit_Z)
00320 :REM ***** Important, this routine must be included after "Key$.FN" :
00322 :
00324 :REM Edit_Fmt = 0 is AlphaNumeric ALL UPPER CASE
00326 :REM Edit_Fmt = 1 is Numeric-Only ( POSITIVE INTEGER )
00328 :REM Edit_Fmt = 2 is AlphaNumeric Upper and Lower
00330 :REM Edit_Fmt = 3 is YN Format ( case-insensitive )
00332 :REM Edit_Fmt = 4 is Numeric ( Negative and Real Numbers ( Decimal Point ) )
00334 :REM
00336 :REM All termination Keys save the data except ESC which restores the returned
00338 :REM value to pre-Edit status.
00340 :REM For Now Termination Keys Are : Enter, DArrow, UArrow, T_A_B,
00342 :REM Shift_T_A_B, PgUp,PgDn, Function
00344 :REM Keys 1-10, ESC
00346 :
00348 :REM KeyValue - A global variable with the code of the final Key pressed.
00350 :REM It is returned by FN Key$
00352 :REM Edit_Z - The current Offset of Edit cursor ( 1 = Left Most Position )
00354 :REM Lgth_Z - The Maximum length of the data being entered.
00356 :REM Data is buffered out to that length by spaces.
00358 :REM Row,Col - X,Y Cordinates of start of data on screen ( 0,0 relative )
00360 :REM ThisPtr - The Pointer to beginning of data for easy updating
00362 :REM Edit_Ins - BOOLEAN variable that indicates Insert Mode ( Not Relative
00364 :REM to Keyboard Indicator )
00366 :REM ReWrt - BOOLEAN variable that is set to TRUE when the entire
00368 :REM string needs to be re-written on the screen
00370 :REM TempOld$- Contains data while being Editted
00372 :REM Z_Key$ - Actual character returned from FN Key$
00374 :REM Edit_Leave- BOOLEAN variable to indicate if the Edit$ should be exitted
00376 :REM when the field is full
00378 :REM
00380 IF Edit_FMT > 89 THEN Edit_FMT = Edit_FMT - 90
00382 PSTR$(Alpha%) = "0123456789.- ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,!@ #$%^&*()_-=+][}{':;/?.>,<\|"
00384 Edit_Z = 1 :REM Set Cursor To Left Most Position
00386 SP_C = 32 :REM Ascii Value Of The space Character
00388 TEMPOLD$ = OLD$ + STRING$(LGTH_Z-LEN(OLD$),Edit_FLCH)
00390 Thisptr = VARPTR(TEMPOLD$)
00392 COLOR ,(Edit_B<<4)+Edit_F
00394 LONG IF Edit_BRKT
00396 LOCATE COL-1,ROW,0 :PRINT "["
00398 LOCATE COL+LGTH_Z,ROW,0:PRINT "]"
00400 END IF
00402 REWRT = TRUE
00404 Edit_INS = FALSE
00406 :REM === Enter Infinite Loop ( You'll See......... )
00408 WHILE (1=1)
00410 :REM == Check to see if string needs to be updated on screen
00412 :REM the 0 in locate turns off the cursor
00414 LONG IF REWRT
00416 LOCATE COL,ROW,0
00418 PRINT TEMPOLD$
00420 REWRT = FALSE
00422 END IF
00424 LONG IF Edit_INS :REM Assert - Set Size Of Cursor
00426 LOCATE COL+Edit_Z-1,ROW,1,0,7
00428 XELSE
00430 LOCATE COL+Edit_Z-1,ROW,1,6,7
00432 END IF
00434 Z_Key$ = FN Key$
00436 :REM ============= The Following Keys Will Leave Edit
00438 :
00440 IF KeyValue = DArrow THEN "Leave Edit Loop"
00442 IF KeyValue = UArrow THEN "Leave Edit Loop"
00444 IF KeyValue = PGDN THEN "Leave Edit Loop"
00446 IF KeyValue = PGUP THEN "Leave Edit Loop"
00448 IF KeyValue = ENTER THEN "Leave Edit Loop"
00450 IF KeyValue = T_A_B THEN "Leave Edit Loop"
00452 IF KeyValue = ESC THEN "Leave Edit Loop"
00454 IF KeyValue = ST_A_B THEN "Leave Edit Loop"
00456 IF KeyValue >= F1 AND KeyValue <= F10 THEN "Leave Edit Loop"
00458 :
00460 :REM ===== Check For Edit Control Keys
00462 IF KeyValue = LArrow THEN "Edit Left Arrow"
00464 IF KeyValue = RArrow THEN "Edit Right Arrow"
00466 IF KeyValue = BACKSP THEN "Edit Back Space"
00468 IF KeyValue = INS THEN "Edit Insert Key"
00470 IF KeyValue = HOME THEN "Edit Home Key"
00472 IF KeyValue = E_N_D THEN "Edit End Key"
00474 IF KeyValue = DEL THEN "Edit Delete Key"
00476 IF KeyValue = CTRLE_N_D THEN "Edit Ctrl End"
00478 GOTO "No Control Key Pressed"
00480 "Edit Ctrl End" REM ========== Ctrl End ============
00482 :REM Deletes Under Cursor and All to right
00484 FOR IZ = Edit_Z TO LGTH_Z
00486 POKE Thisptr+IZ,Edit_FLCH
00488 NEXT IZ
00490 GOTO "Edit Bottom"
00492 "Edit Insert Key"REM ========== Insert Key ===========
00494 : REM Just Toggle Insert State "Edit_Ins"
00496 Edit_INS = NOT Edit_INS
00498 GOTO "Edit Bottom"
00500 "Edit Delete Key"REM ============ Delete Key ===============
00502 :REM Deletes character under the cursor and "pulls" data to the
00504 :REM right of the cursor one position to the left.
00506 LONG IF Edit_Z <> LGTH_Z
00508 FOR IZ = Edit_Z TO LGTH_Z-1
00510 POKE Thisptr+IZ, PEEK(Thisptr+IZ+1)
00512 NEXT IZ
00514 END IF
00516 :REM == Don't Forget To Fill In last Character With blank
00518 POKE Thisptr+LGTH_Z,Edit_FLCH
00520 REWRT = TRUE
00522 GOTO "Edit Bottom"
00524 "Edit Left Arrow" REM ========= Left Arrow ==============
00526 IF ( Edit_Z = 1 ) THEN "Edit Beep Bottom"
00528 Edit_Z = Edit_Z -1
00530 GOTO "Edit Bottom"
00532 "Edit Right Arrow" REM ========= Right Arrow ============
00534 IF ( Edit_Z = LGTH_Z) THEN "Edit Beep Bottom"
00536 Edit_Z = Edit_Z + 1
00538 GOTO "Edit Bottom"
00540 "Edit Home Key" REM ========= Home Key ===============
00542 IF ( Edit_Z = 1 ) THEN "Edit Beep Bottom"
00544 Edit_Z = 1
00546 GOTO "Edit Bottom"
00548 "Edit End Key" REM ========= End Key ==============
00550 :REM This search from the right-most position until a non-blank character
00552 :REM is found or the left-most position is reached
00554 IF ( Edit_Z=LGTH_Z ) THEN "Edit Beep Bottom"
00556 Edit_Z = LGTH_Z
00558 WHILE ( Edit_Z > 1 ) AND ( PEEK(Thisptr+Edit_Z) = Edit_FLCH)
00560 Edit_Z = Edit_Z -1
00562 WEND : IF Edit_Z < LGTH_Z THEN Edit_Z = Edit_Z + 1 : ': next space open
00564 GOTO "Edit Bottom"
00566 "Edit Back Space" REM ========= Backspace Key ==============
00568 :REM Deletes Character to the Left of the cursor and "pulls" all data
00570 :REM under and to the right of the cursor one position to the left
00572 IF Edit_Z = 1 THEN "Edit Beep Bottom"
00574 FOR BCK = Edit_Z-1 TO LGTH_Z-1
00576 POKE Thisptr+BCK, PEEK(Thisptr+BCK+1)
00578 NEXT BCK
00580 POKE Thisptr+LGTH_Z, Edit_FLCH
00582 Edit_Z = Edit_Z - 1 : REWRT = TRUE
00584 GOTO "Edit Bottom"
00586 "No Control Key Pressed"
00588 :REM =============================================
00590 :REM ===== Check For Valid Key Pressed ===========
00592 :REM =============================================
00594 :
00596 IF ( NOT Isaski) THEN "Edit Beep Bottom"
00598 :
00600 :REM - Check For Only Numeric if format demands it
00602 :
00604 IF ( Edit_FMT = 1 ) AND ( INSTR(1,PSTR$(Alpha),Z_Key$) > 10) THEN "Edit Beep Bottom"
00606 IF ( Edit_FMT = 4 ) AND ( INSTR(1,PSTR$(Alpha),Z_Key$) > 12) THEN "Edit Beep Bottom"
00608 :
00610 LONG IF ( Edit_FMT = 3 )
00612 :REM Assert : Check For "Y" or "N"
00614 : Z_Key$ = UCASE$(Z_Key$)
00616 : IF ( Z_Key$ <> "Y" ) AND ( Z_Key$ <> "N" ) THEN "Edit Beep Bottom"
00618 END IF
00620 :
00622 :REM =========================== Valid Key Pressed
00624 :REM
00626 :REM ==== Here is the only place for a new character to be updated to
00628 :REM the string. You will only be here if an ascii character
00630 :REM has been inputted and if it is in the valid format.
00632 :
00634 IF Edit_FMT = 0 THEN Z_Key$ = UCASE$(Z_Key$)
00636 :REM Check For Insert Status
00638 LONG IF Edit_INS
00640 :REM Assert : This will only shift the character one position to
00642 :REM the right. The character will be inserted later
00644 :REM Check For Full String
00646 IF ( PEEK(Thisptr+LGTH_Z) <> Edit_FLCH ) THEN "Edit Beep Bottom"
00648 :REM IF String Lgth_Z is One, Loop will crash
00650 LONG IF LGTH_Z > 1
00652 FOR IZ = LGTH_Z TO Edit_Z+1 STEP -1
00654 POKE Thisptr+IZ, PEEK(Thisptr+IZ-1)
00656 NEXT IZ
00658 END IF
00660 REWRT = TRUE
00662 END IF
00664 LONG IF ASC(Z_Key$) = SP_C
00666 POKE Thisptr+Edit_Z, Edit_FLCH
00668 LOCATE COL+Edit_Z-1,ROW,0:PRINT CHR$(Edit_FLCH);
00670 XELSE
00672 POKE Thisptr+Edit_Z, ASC(Z_Key$)
00674 LOCATE COL+Edit_Z-1,ROW,0:PRINT Z_Key$;
00676 END IF
00678 LONG IF Edit_Z < LGTH_Z
00680 Edit_Z = Edit_Z + 1
00682 GOTO "Edit Bottom"
00684 XELSE
00686 :REM Assert : Field is full, Check to see if an exit is in order !
00688 IF Edit_LEAVE THEN KeyValue = ENTER:GOTO "Leave Edit Loop"
00690 END IF
00692 "Edit Beep Bottom"
00694 SOUND 500,500
00696 "Edit Bottom"
00698 WEND
00700 "Leave Edit Loop"
00702 REM == Check for Escape Key Pressed
00704 IF KeyValue = ESC THEN TEMPOLD$ = OLD$ + SPACE$(LGTH_Z-LEN(OLD$))
00706 FOR IZ = 1 TO LGTH_Z
00708 IF PEEK(Thisptr+IZ) = Edit_FLCH THEN POKE Thisptr+IZ,SP_C
00710 NEXT IZ
00712 REM == Clean Off Brackets before leaving
00714 COLOR ,(Edit_BR<<4)+Edit_FR
00716 LONG IF Edit_BRKT
00718 LOCATE COL-1,ROW,0 :PRINT " "
00720 LOCATE COL+LGTH_Z,ROW,0:PRINT " "
00722 END IF
00724 LOCATE COL,ROW,0:PRINT TEMPOLD$
00726 END FN = TEMPOLD$
00728 :REM
00730 :REM End Of FN Edit$
00800 CLS:FIELD=1:REM: initialize field count
00810 FN Edit_DFLTS(1,7,7,1,32,TRUE,TRUE)
00820 FOR T=1 TO 10:LX(T)=10:LY(T)=T+4:LOCATE LX(T) - 4,LY(T):PRINT USING"##. ";T
00830 NEXT T
00840 PRINT TAB(10)"Press {F10} to Quit"
00890 Edit_Z=1:REM: initialize cursor location
00900 DO:': START OF Edit LOOP
00910 :IN$(FIELD)=FN Edit$(IN$(FIELD),LX(FIELD),LY(FIELD),20,2,Edit_Z)
00920 :IF KeyValue=UArrow THEN FIELD=FIELD-1 :': up Arrow
00930 :IF KeyValue=ENTER THEN FIELD=FIELD+1:': move down on enter
00940 :IF KeyValue=DArrow THEN FIELD=FIELD+1 :': down Arrow
00980 :IF FIELD<1 THEN FIELD=10
00982 :IF FIELD>10 THEN FIELD=1
00990 UNTIL KeyValue=F10:': END OF Edit LOOP
01000 :LOCATE 0,23:END